home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 6984 / 6984.xpi / chrome / lazarus.jar / content / sanitize-overlay.js < prev    next >
Text File  |  2009-11-24  |  3KB  |  85 lines

  1.  
  2. this.Lazarus = this.Lazarus || {};
  3.  
  4. Lazarus.initalized = false;
  5.  
  6. /**
  7. * initalize window
  8. */
  9. Lazarus.init = function(){
  10.     if (!Lazarus.initalized){
  11.         Lazarus.initalized = true;
  12.         window.removeEventListener("load", Lazarus.init, false);
  13.         
  14.         //attach an event to the ondialogaccept command
  15.         window.addEventListener("dialogaccept", Lazarus.onDialogAccept, false);
  16.         
  17.                 //bugger! Firefox 3.5 introduces a remove search history by date option 
  18.                 //eg remove the last X hours. 
  19.                 if (Lazarus.$("detailsExpanderWrapper")){
  20.                     Lazarus.$('extensions.lazarus.privacy.item.saved.forms.checkbox').hidden = true;
  21.                 }
  22.                 else {
  23.                     //move our checkbox beneath the "Save form and search history" checkbox
  24.                     var lazBox = Lazarus.$('extensions.lazarus.privacy.item.saved.forms.checkbox');
  25.                     var checkboxes = document.getElementsByTagName("checkbox");
  26.                     for (var i=0; i<checkboxes.length; i++){
  27.                             var box = checkboxes[i];
  28.                             if (box.getAttribute("preference") == "privacy.item.formdata" && box.nextSibling){
  29.                                     box.parentNode.insertBefore(lazBox, box.nextSibling);
  30.                                     break;
  31.                             }
  32.                     }
  33.                     //if not found , leave at end of list
  34.             }
  35.    }
  36. }
  37.  
  38. /**
  39. * cleanup
  40. */
  41. Lazarus.cleanup = function(){
  42.     if (Lazarus.initalized){
  43.         window.removeEventListener("dialogaccept", Lazarus.onDialogAccept, false);
  44.     }
  45. }
  46.  
  47. /**
  48. * user hit "Clear Private Data Now"
  49. */
  50. Lazarus.onDialogAccept = function(){
  51.     
  52.     if (Lazarus.$('extensions.lazarus.privacy.item.saved.forms.checkbox').checked){
  53.         var browser = Lazarus.getBrowser();
  54.         if (browser){
  55.             browser.Lazarus.emptyDB(Lazarus.FORM_TYPE_TEMPLATE);
  56.             browser.Lazarus.debug("ClearPrivateData: removing all forms");        
  57.             //hitting clear now also logs a user out of the Software Security Device
  58.             browser.Lazarus.refreshIcon();
  59.         }
  60.         else {
  61.             /*
  62.             if privacy.sanitize.promptOnSanitize = true and 
  63.                 privacy.sanitize.sanitizeOnShutdown = true
  64.             then the Clear Private Data dialog is opened on shutdown.
  65.             At this point there are no browser windows, so we cannot call any code from Lazarus.getBrowser()
  66.             */
  67.             //we need to connect to the database, and remove all forms (but not templates)
  68.             Lazarus.db = new Lazarus.SQLite("%profile%/lazarus.sqlite");
  69.                         var ids = Lazarus.db.getColumn("SELECT id FROM forms WHERE savetype NOT IN ("+ Lazarus.FORM_TYPE_TEMPLATE +")");
  70.                         
  71.                         Lazarus.db.exe("DELETE FROM forms WHERE id IN ("+ ids.join(",") +")");
  72.                         Lazarus.db.exe("DELETE FROM forms_fulltext WHERE docid IN ("+ ids.join(",") +")"); 
  73.                         
  74.                         //and remove editor info too
  75.                         Lazarus.db.exe('DELETE FROM textdata');
  76.                         Lazarus.db.exe('DELETE FROM textdata_fulltext');
  77.             
  78.                         Lazarus.db.close();
  79.         }
  80.     }
  81. }
  82.  
  83. window.addEventListener("load", Lazarus.init, false);
  84. window.addEventListener("close", Lazarus.cleanup, false);
  85.